package com.lc1993929.chapter21.ThreadException;

import java.util.concurrent.ThreadFactory;

/**
 * Created by LiuChang on 2018/9/19.
 */
public class HandlerThreadFactory implements ThreadFactory {
    @Override
    public Thread newThread(Runnable r) {
        System.out.println(this + " creating new Thread");
        Thread t = new Thread(r);
        System.out.println("created " + t);
        t.setUncaughtExceptionHandler(
                new MyUncaughtExceptionHandler()
        );
        System.out.println("eh = " + t.getUncaughtExceptionHandler());
        return t;
    }
}
